package com.cyy.common.constant;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;

@Getter
@AllArgsConstructor
public enum CommentSource {
    COMMENT("COMMENT", "文章评论"),
    MESSAGE("MESSAGE", "留言板"),
    LINK("LINK", "友链页面留言");

    private final String code;

    private final String desc;

    public static String typeJudge(Integer articleId) {
        if (Objects.isNull(articleId)) {
            return null;
        }
        return articleId == 0 ? MESSAGE.code : COMMENT.code;
    }

    /**
     * 判断是否需要登录
     * @param source
     * @return
     */
    public static boolean needLogin(String source) {
        return !source.equals(MESSAGE.code);
    }
}
